package com.dou361.jjdxm_ijkplayer;

import android.app.Application;
import android.content.Context;

import com.danikula.videocache.HttpProxyCacheServer;
import com.dou361.jjdxm_ijkplayer.utlis.CommonConfig;

import java.io.File;

/**
 * 描述:
 * 创建: zhangyh
 * 时间: 2018/11/28
 */

public class MyApplication extends Application {
    private static MyApplication mApplication;//test

    public static MyApplication Instance() {
        return mApplication;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mApplication = this;
        CommonConfig.instance();
    }

    private HttpProxyCacheServer proxy;

    public static HttpProxyCacheServer getProxy(Context context) {
        MyApplication app = (MyApplication) context.getApplicationContext();
        return app.proxy == null ? (app.proxy = app.newProxy()) : app.proxy;
    }

    private HttpProxyCacheServer newProxy() {
        return new HttpProxyCacheServer.Builder(this)
                .cacheDirectory(new File(CommonConfig.instance().CACHE))
                .build();
//        return  new HttpProxyCacheServer(this);
    }
}
